<?php

  define('BASE_ROOT_PATH', dirname(dirname(__FILE__)));
	include_once( BASE_ROOT_PATH . "/word/db/DBMySQL.php");  

	$order = $_REQUEST['order'];
	if(!isset($order))
	{
		$order = 0;
	}
	
	$orderStr = "school_en";
	if($order == 1)
	{
		$orderStr = "school_order";
	}
	
	$db = new DBMySQL();
	$rs = $db->Query("select sc.school_id,sc.school_en,sc.school_cn,sc.school_order,sc.school_state from t_school as sc order by $orderStr");
	//echo "select sc.school_id,sc.school_en,sc.school_cn,sc.school_order,sc.school_state from t_school order by $orderStr";
	if(empty($rs)) {
	  $msg = json_encode("学校列表为空");
		echo '{"code":"1","msg":'.$msg.'}';
		exit();
	}
  	$nSize = count($rs);
  	$data = array();
  	
  	for($i=0;$i<$nSize;$i++) {
  	  	$val = $rs[$i];
  	  
	    	$schoolId= $val['school_id'];
	    			
	    	$schoolEn = $val['school_en'];
	    	if(empty($schoolEn)) {
	    	  $schoolEn = '';
	    	}		
	    	
		$schoolCn = $val['school_cn'];
	    	if(empty($schoolCn)) {
	    	  $schoolCn = '';
	    	}		
	    	
	    	$schoolState = $val['school_state'];
	    	if(empty($schoolState)) {
	    	  $schoolState = '';
	    	}	
	    	$order = $val['school_order'];
	    	$item = array(
	    		"schoolId"=>$schoolId,
	    		"schoolEn"=>$schoolEn,
	    		"schoolCn"=>$schoolCn,
	    		"schoolState"=>$schoolState,
	    		"order"=>$order);
	    	$data[]=$item;			
	}
	
  $dataStr = json_encode($data);
	
	echo '{"code":"0","msg":"","total":"'.$nSize .'","data":'.$dataStr.'}';
	
?>